/** @file ShootCommand
    @class ShootCommand
    @brief Command that fires a shoot from a player avatar

    description
*/
#ifndef __ShootCommand_h_
#define __ShootCommand_h_

#include "Command.h"

class ShootCommand : public Command {
public:
	/**
	* The constructor
	*/
	ShootCommand (unsigned int playerId)
		: Command(playerId) {}
	
	/**
	* The empty constructor
	*/
	ShootCommand() {}
		
	/**
	* The deconstructor
	*/
	virtual ~ShootCommand(void) {}
	
	/**
	* Executs the command on argument model
	*/
	virtual bool execute(Model *model) {
		GameObject *gameObject = model->getByID(getPlayerId());
		if ( gameObject == NULL) {
			return false;
		} else {
			PlayerAvatar* pa = dynamic_cast<PlayerAvatar*>(gameObject);
			pa->fire();
			return true;
		}
	}
	
	/**
	* Saves the command to a output file stream
	*/
	virtual void save(ofstream &ofs) {
		int i = SHOOTCOMMAND;
		ofs.write((char*) &i, sizeof(int));
		Command::save(ofs);
  }

	/**
	* Loads a command from a input file stream
	*/
  virtual void load(ifstream &ifs) {
		Command::load(ifs);
  }

	/**
	* Saves the command to a bit stream
	*/
  virtual void save(RakNet::BitStream &ofs) {
		int i = SHOOTCOMMAND;
		ofs.Write((char*) &i, sizeof(int));
		Command::save(ofs);
  }

	/**
	* Loads a command from a bit stream
	*/
  virtual void load(RakNet::BitStream &ifs) {
		Command::load(ifs);
  }

private:
	
};

#endif